// To parse this JSON data, do
//
//     final vipInfo = vipInfoFromJson(jsonString);

import 'dart:convert';

import 'package:flutter_nb_net/flutter_net.dart';

VipInfoResp vipInfoFromJson(String str) => VipInfoResp.fromJson(json.decode(str));

String vipInfoToJson(VipInfoResp data) => json.encode(data.toJson());

class VipInfoResp extends BaseNetModel {
  int? code;
  String? msg;
  VipInfoData? data;

  VipInfoResp({
    this.code,
    this.msg,
    this.data,
  });

  factory VipInfoResp.fromJson(Map<String, dynamic> json) => VipInfoResp(
    code: json["code"],
    msg: json["msg"],
    data: json["data"] == null ? null : VipInfoData.fromJson(json["data"]),
  );

  Map<String, dynamic> toJson() => {
    "code": code,
    "msg": msg,
    "data": data?.toJson(),
  };

  @override
  fromJson(Map<String, dynamic> json) {
    return VipInfoResp.fromJson(json);
  }
}

class VipInfoData extends BaseNetModel {
  String? deviceName;
  String? imei;
  bool? activated;
  DeviceRenewal? deviceRenewal;
  List<VipPackage>? packages;

  VipInfoData({
    this.deviceName,
    this.imei,
    this.activated,
    this.deviceRenewal,
    this.packages,
  });

  factory VipInfoData.fromJson(Map<String, dynamic> json) => VipInfoData(
    deviceName: json["deviceName"],
    imei: json["imei"],
    activated: json["activated"],
    deviceRenewal: json["deviceRenewal"] == null ? null : DeviceRenewal.fromJson(json["deviceRenewal"]),
    packages: json["packages"] == null ? [] : List<VipPackage>.from(json["packages"]!.map((x) => VipPackage.fromJson(x))),
  );

  Map<String, dynamic> toJson() => {
    "deviceName": deviceName,
    "imei": imei,
    "activated": activated,
    "deviceRenewal": deviceRenewal?.toJson(),
    "packages": packages == null ? [] : List<dynamic>.from(packages!.map((x) => x.toJson())),
  };

  @override
  fromJson(Map<String, dynamic> json) {
    return VipInfoData.fromJson(json);
  }
}

class DeviceRenewal extends BaseNetModel {
  bool? expired;
  String? expireTime;

  DeviceRenewal({
    this.expired,
    this.expireTime,
  });

  factory DeviceRenewal.fromJson(Map<String, dynamic> json) => DeviceRenewal(
    expired: json["expired"],
    expireTime: json["expireTime"] ,
  );

  Map<String, dynamic> toJson() => {
    "expired": expired,
    "expireTime": expireTime,
  };

  @override
  fromJson(Map<String, dynamic> json) {
    return DeviceRenewal.fromJson(json);
  }
}

class VipPackage extends BaseNetModel {
  int? packageType;
  String? packageTypeName;
  List<VipPackageInfo>? packageInfos;

  VipPackage({
    this.packageType,
    this.packageTypeName,
    this.packageInfos,
  });

  factory VipPackage.fromJson(Map<String, dynamic> json) => VipPackage(
    packageType: json["packageType"],
    packageTypeName: json["packageTypeName"],
    packageInfos: json["packageInfos"] == null ? [] : List<VipPackageInfo>.from(json["packageInfos"]!.map((x) => VipPackageInfo.fromJson(x))),
  );

  Map<String, dynamic> toJson() => {
    "packageType": packageType,
    "packageTypeName": packageTypeName,
    "packageInfos": packageInfos == null ? [] : List<dynamic>.from(packageInfos!.map((x) => x.toJson())),
  };

  @override
  fromJson(Map<String, dynamic> json) {
    return VipPackage.fromJson(json);
  }
}

class VipPackageInfo extends BaseNetModel {
  int? id;
  int? vipPackageId;
  String? name;
  double? price;
  int? originalPrice;
  int? durationNum;
  int? durationUnit;
  String? description;

  VipPackageInfo({
    this.id,
    this.vipPackageId,
    this.name,
    this.price,
    this.originalPrice,
    this.durationNum,
    this.durationUnit,
    this.description,
  });

  factory VipPackageInfo.fromJson(Map<String, dynamic> json) => VipPackageInfo(
    id: json["id"],
    vipPackageId: json["vipPackageId"],
    name: json["name"],
    price: json["price"]?.toDouble(),
    originalPrice: json["originalPrice"],
    durationNum: json["durationNum"],
    durationUnit: json["durationUnit"],
    description: json["description"],
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "vipPackageId": vipPackageId,
    "name": name,
    "price": price,
    "originalPrice": originalPrice,
    "durationNum": durationNum,
    "durationUnit": durationUnit,
    "description": description,
  };

  @override
  fromJson(Map<String, dynamic> json) {
    return VipPackageInfo.fromJson(json);
  }
}
